﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Posting.aspx.cs" Inherits="_Default" MasterPageFile="~/Student/Student.master" Title = "Posting Page"%>


<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxUploadControl" tagprefix="dx" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="HeadContent">
    <script type="text/javascript">
    // <![CDATA[
        function Uploader_OnUploadStart() {
            btnUpload.SetEnabled(false);
        }
        function Uploader_OnFileUploadComplete(args) {
            var imgSrc = aspxPreviewImgSrc;
            if (args.isValid) {
                var date = new Date();
                imgSrc = "UploadImages/" + args.callbackData + "?dx=" + date.getTime();
            }
            getPreviewImageElement().src = imgSrc;
        }
        function Uploader_OnFilesUploadComplete(args) {
            UpdateUploadButton();
        }
        function UpdateUploadButton() {
            btnUpload.SetEnabled(uploader.GetText(0) != "");
        }
        function getPreviewImageElement() {
            return document.getElementById("previewImage");
        }        
    // ]]> 
    </script>

    <style type="text/css">
        .style1
        {
            width: 99px;
        }
    </style>
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" >
    <asp:MultiView ID="mulviewPosting" runat="server">
        <asp:View ID="viwPosting" runat="server">
        <dx:ASPxLabel ID="lbError" runat="server" ForeColor="Red">
        </dx:ASPxLabel>
&nbsp;<table border="0" cellpadding="0" cellspacing="0" id="mainContainer">
        <tr>
            <td valign="top" align="center" class="content">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="center" style="padding-right: 20px; vertical-align: top;">
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="caption">
                                        <dx:ASPxLabel ID="ASPxLabel1" runat="server" 
                                            CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                                            Text="Select Image:">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td>
                                        <dx:ASPxUploadControl ID="uplImage" runat="server" 
                                            ClientInstanceName="uploader" CssFilePath="~/App_Themes/DevEx/{0}/styles.css" 
                                            CssPostfix="DevEx" ShowProgressPanel="True" Size="35" 
                                            SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css" 
                                            UploadMode="Advanced" onfileuploadcomplete="uplImage_FileUploadComplete">
                                            <ValidationSettings MultiSelectionErrorText="Attention!

                                                The following {0} files are invalid because they exceed the allowed file size ({1}) or their extensions are not allowed. These files have been removed from selection, so they will not be uploaded. 

                                                {2}" allowedfileextensions=".jpg, .jpeg, .jpe, .gif" maxfilesize="4194304">
                                            </ValidationSettings>                                                                      
                                            
                                            <clientsideevents fileuploadstart="function(s, e) { Uploader_OnUploadStart(); }" 
                                                textchanged="function(s, e) { UpdateUploadButton(); }" 
                                                FilesUploadComplete="function(s, e) { Uploader_OnFilesUploadComplete(e); }" 
                                                FileUploadComplete="function(s, e) { Uploader_OnFileUploadComplete(e); }" />
                                            
                                        </dx:ASPxUploadControl>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td class="note">
                                        <dx:ASPxLabel ID="ASPxLabel2" runat="server" 
                                            CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                                            Text="Allowed image types: jpeg, gif">
                                        </dx:ASPxLabel>
                                        <br />
                                        <dx:ASPxLabel ID="ASPxLabel3" runat="server" 
                                            CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                                            Text="Maximum file size: 4Mb">
                                        </dx:ASPxLabel>
                                        <br />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center" class="buttonCell">
                                        <dx:ASPxButton ID="btnUpload" runat="server" 
                                            ClientEnabled="False" ClientInstanceName="btnUpload" 
                                            CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                                            SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css" Text="Upload" 
                                            Width="100px" onclick="btnUpload_Click" CausesValidation="False" 
                                            AutoPostBack="False">
                                            <clientsideevents click="function(s, e) {
	                                                                                    uploader.Upload();
                                                                                    }" />
                                        </dx:ASPxButton>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td align="center" class="imagePreviewCell">
                            <img src="../Images/ImagePreview.gif" id="previewImage" alt="" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <table width="100%"> 
        <tr>
            <td class="style4">
                <dx:ASPxLabel ID="ASPxLabel4" runat="server" 
                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                    Text="Description:">
                </dx:ASPxLabel>
            </td>            
            <td class="style3">
                <dx:ASPxMemo ID="memoDescription" runat="server" 
                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                    Height="150px" SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css" 
                    style="margin-left: 0px" Width="500px">
                    <ValidationSettings Display="Dynamic" SetFocusOnError="True">
                        <RequiredField ErrorText="Description not null!" IsRequired="True" />
                    </ValidationSettings>
                </dx:ASPxMemo>
            </td>            
        </tr>
        <tr>
            <td class="style4">
                <dx:ASPxLabel ID="ASPxLabel5" runat="server" 
                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                    Text="Price:">
                </dx:ASPxLabel>
            </td>            
            <td class="style3">
                <table style="width:100%;">
                    <tr>
                        <td class="style1">
                <dx:ASPxTextBox ID="txtPrice" runat="server" Width="100px" 
                                CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                                SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css">
                    <MaskSettings ErrorText="Price invalid!" 
                        Mask="&lt;0..999999g&gt;.&lt;000..999&gt;" />
                    <ValidationSettings Display="Dynamic">
                        <RegularExpression ErrorText="Price must be number!" />
                    </ValidationSettings>
                </dx:ASPxTextBox>
                        </td>
                        <td>
                            VNĐ</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
            </td>            
        </tr>
        <tr>
            <td class="style4">
                <dx:ASPxLabel ID="ASPxLabel6" runat="server" 
                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                    Text="Date:">
                </dx:ASPxLabel>
            </td>            
            <td class="style3">
                <dx:ASPxTextBox ID="txtDate" runat="server" 
                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                    ReadOnly="True" SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css" 
                    Width="170px">
                </dx:ASPxTextBox>
            </td>            
        </tr>
        <tr>
            <td class="style4">&nbsp;</td>            
            <td class="style3">
                <dx:ASPxButton ID="btPosting" runat="server" 
                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
                    SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css" Text="Posting" 
                    onclick="btPosting_Click" ClientInstanceName="btnPosting">
                </dx:ASPxButton>
            </td>            
        </tr>
    </table>
        </asp:View>
        <asp:View ID="viwError" runat="server">
            <table width=100%>
                <tr>
                    <td align="center">
                        <asp:Label ID="lbStatus" runat="server" ForeColor="Red">
                        </asp:Label>
                    </td>
                </tr>
            </table>
        </asp:View>
    </asp:MultiView>
    
      <script type="text/javascript">
        // <![CDATA[
              var aspxPreviewImgSrc = getPreviewImageElement().src;
        // ]]> 
      </script>  
</asp:Content>


